package mop.exception;

import java.sql.Timestamp;

/**
 * Exception class to be thrown when business rule 1 is violated
 * 
 * @author	 MOP Team 7
 */

public class IllegalDateException extends Throwable{


	/**
	 * Initializes an IllegalDateException with the problematic date
	 * 
	 * @param date	The problematic date
	 *  
	 * @effect Sets the date
	 * 	|this.setDate(date);
	 */
	public IllegalDateException(Timestamp date)
	{
		this.setDate(date);
	}
	
	/**
	 * Return a error message that can be used by the GUI
	 * @return An error message describing the incorrect name
	 */
	public String toString()
	{
		
		StringBuffer sb = new StringBuffer();
		sb.append("Given date is invalid ! : ");
		sb.append(this.date);
		return sb.toString();
		
	}
	
	 /**
	  * Set the date
	  * 
	  * @param date	The problematic date
	  *  
	  * @post The date is set to the passed one
	  * |this.date ==  date
	  */
	 private void setDate(Timestamp date) 
	 {
		 this.date = date;
	 }
	 
	 /**
	  * Returns the date
	  * @return date
	  */
	 public Timestamp getDate() 
	 {
		 return date;
	 }
	
	/**
	 * weird java demand
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * the problematic date
	 */
	private Timestamp date;
		
	

}
